import http from "@/api";
import { ORDER_PORT } from "@/api/config/servicePort";
import { Order, ResPage } from "@/api/interface";

export const getOrderList = (params: Order.ReqOrder) => {
  return http.post<ResPage<Order.ResOrder>>(ORDER_PORT + `/list`, params, { loading: false });
};

export const updateOrderStatus = (params: Order.ReqOrder) => {
  return http.put(ORDER_PORT + `/status`, params, { loading: false });
};

export const getOrderStatus = () => {
  return http.get(ORDER_PORT + `/status`);
};

export const editOrder = (params: Order.ReqOrder) => {
  return http.post(ORDER_PORT + `/edit`, params, { loading: false });
};

export const getOrderPayType = () => {
  return http.get(ORDER_PORT + `/pay_type`);
};

export const getOrderDeliveryType = () => {
  return http.get(ORDER_PORT + `/delivery_type`);
};

export const deliveryOrderAPI = (params: { id: string[] }) => {
  return http.put(ORDER_PORT + `/delivery`, params, { loading: false });
};

export const exportOrder = (params: Order.ReqOrder) => {
  return http.download(ORDER_PORT + `/export`, params);
};
